package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;
import com.corona.game.util.TextureCache;
import java.util.HashMap;
import java.util.Map;

/* compiled from: Menu.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawBattleMenuSafariZone.class */
public class DrawBattleMenuSafariZone extends Action {
    public Action.Layer layer = Action.Layer.gui_129;
    Map<String, Vector2> getCoords = new HashMap();
    Sprite arrow = new Sprite(TextureCache.get(Gdx.files.internal("battle/arrow_right1.png")), 0, 0, 5, 7);
    Sprite textBox = new Sprite(TextureCache.get(Gdx.files.internal("battle/battle_text_safarizone.png")), 0, 0, 160, 144);
    Vector2 newPos = new Vector2(9.0f, 24.0f);
    String curr = "tl";

    public DrawBattleMenuSafariZone(Game game, Action nextAction) {
        super(new Object[0]);
        this.nextAction = nextAction;
        this.getCoords.put("tr", new Vector2(105.0f, 24.0f));
        this.getCoords.put("tl", new Vector2(9.0f, 24.0f));
        this.getCoords.put("br", new Vector2(105.0f, 8.0f));
        this.getCoords.put("bl", new Vector2(9.0f, 8.0f));
        this.arrow.setPosition(this.newPos.x, this.newPos.y);
    }

    @Deprecated
    Action calcIfCaught(Game game) {
        boolean breaksFree;
        int randomNum = game.map.rand.nextInt(150 + 1);
        int adrenaline = game.player.adrenaline;
        if (adrenaline > 25) {
            adrenaline = 25;
        }
        int f = (int) Math.floor((double) (((game.battle.oppPokemon.currentStats.get("catchRate").intValue() * 255) * 4) / (100 * 15)));
        if (randomNum - 0 > game.battle.oppPokemon.currentStats.get("catchRate").intValue()) {
        }
        int randomNum_M = game.map.rand.nextInt(256);
        if (f + (adrenaline * 10) >= randomNum_M) {
            breaksFree = false;
        } else {
            breaksFree = true;
        }
        System.out.println("(randomNum_M / f / adr): (" + String.valueOf(randomNum_M) + " / " + String.valueOf(f) + " / +" + String.valueOf(adrenaline * 10) + ")");
        if (!breaksFree) {
            return new CatchPokemonWobblesThenCatch(game, "", this);
        }
        int d = (game.battle.oppPokemon.currentStats.get("catchRate").intValue() * 100) / 150;
        if (d >= 256) {
            return new CatchPokemonWobbles3Times(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
        }
        int x = ((d * f) / 255) + 0;
        if (x < 10) {
            return new CatchPokemonMiss(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
        }
        if (x < 30) {
            return new CatchPokemonWobbles1Time(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
        }
        if (x < 70) {
            return new CatchPokemonWobbles2Times(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
        }
        return new CatchPokemonWobbles3Times(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (InputProcessor.upPressed) {
            if (this.curr.equals("bl") || this.curr.equals("br")) {
                this.curr = "t" + String.valueOf(this.curr.charAt(1));
                this.newPos = this.getCoords.get(this.curr);
            }
        } else if (InputProcessor.downPressed) {
            if (this.curr.equals("tl") || this.curr.equals("tr")) {
                this.curr = "b" + String.valueOf(this.curr.charAt(1));
                this.newPos = this.getCoords.get(this.curr);
            }
        } else if (InputProcessor.leftPressed) {
            if (this.curr.equals("tr") || this.curr.equals("br")) {
                this.curr = String.valueOf(this.curr.charAt(0)) + "l";
                this.newPos = this.getCoords.get(this.curr);
            }
        } else if (InputProcessor.rightPressed && (this.curr.equals("tl") || this.curr.equals("bl"))) {
            this.curr = String.valueOf(this.curr.charAt(0)) + "r";
            this.newPos = this.getCoords.get(this.curr);
        }
        if (InputProcessor.aJustPressed) {
            if (this.curr.equals("tl")) {
                Action catchAction = calcIfCaught(game);
                String textString = game.player.name + " used SAFARI BALL!";
                if (game.player.adrenaline < 5) {
                    game.insertAction(new DisplayText(game, textString, (String) null, catchAction, new ThrowPokeball(game, catchAction)));
                } else if (game.player.adrenaline < 15) {
                    game.insertAction(new DisplayText(game, textString, (String) null, catchAction, new ThrowFastPokeball(game, catchAction)));
                } else {
                    game.insertAction(new DisplayText(game, textString, (String) null, catchAction, new ThrowHyperPokeball(game, catchAction)));
                }
                game.actionStack.remove(this);
            } else if (this.curr.equals("bl")) {
                Action throwRockAction = new ThrowRock(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
                game.insertAction(new DisplayText(game, game.player.name + " threw a ROCK.", (String) null, throwRockAction, throwRockAction));
                game.actionStack.remove(this);
            } else if (this.curr.equals("tr")) {
                Action throwBaitAction = new ThrowBait(game, new PrintAngryEating(game, new ChanceToRun(game, this)));
                game.insertAction(new DisplayText(game, game.player.name + " threw some BAIT.", (String) null, throwBaitAction, throwBaitAction));
                game.actionStack.remove(this);
            } else if (this.curr.equals("br")) {
                game.actionStack.remove(this);
                game.insertAction(new WaitFrames(game, 18, new DisplayText(game, "Got away safely!", (String) null, (Action) null, new SplitAction(new BattleFadeOut(game, null), new BattleFadeOutMusic(game, null)))));
                game.insertAction(new PlayMusic("click1", new PlayMusic("run1", (Action) null)));
            }
        }
        this.textBox.draw(game.uiBatch);
        this.arrow.setPosition(this.newPos.x, this.newPos.y);
        this.arrow.draw(game.uiBatch);
    }
}
